package eclipse.lib.player;
import eclipse.lib.item.*;
import eclipse.lib.skill.Skill;
import javax.media.opengl.jgloo.*;
import javax.media.opengl.jgloo.jgl2d.*;
/**
 * Represents a Character belonging to the Player Object.
 */
/*
 * Copyright (c) 2009, TOD Productions All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 *	- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 *	- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 *	-Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */
public class Character 
{
	public final JGLSprite sprite = new JGLSprite();
	/** Is the character moving*/
	public boolean 			cMoving  		= false;
	/** Character's sprite index */
	public int 				cSprite			= 0;
	/** Character's current frame */
	public int 				cFrame			= 0;
	/** Direction the character is facing */
	public int 				cDir			= 0;
	/** Map the character is on */
	public int 				cMap			= 0;
	/** Class the character belongs to */
	public Class 			cClass 			= new Class();
	/** Position of the character */
	public final JGLVector		cPos 			= new JGLVector();
	/** The names of all of the stats. */
	public static String[] 	STAT_NAME 			= new String[6];
	/** The maximum number of items that a Character can hold. */
	public static int		MAX_PLAYER_INV;
	/** The maximum number of Spells that a Character can learn. */
	public static int		MAX_PLAYER_SKILLS;
	private boolean buffed;
	private String 	name;
	private float	accuracy;
	private int 	lvl;
	private int 	HP;
	private int 	MP;
	private int		SP;
	private int 	STR;
	private int		DEX;
	private int		SPR;
	private int		INT;
	private int 	def;
	private int		hit = 2;
	private Skill[]	skill;
	private Item[] 	inventory;
	private final Item[]	hand = new Item[2];
	private Item	arms;
	private Item	body;
	private Item	head;
	private Item	legs;
	private Item	neck;
	private Item	ring;
	public Character(){};
	/**
	 * Creates a new Character
	 * @param name Name of the character.
	 */
	public Character(String name /*,class*/ )
	{
		inventory 	= new Item[MAX_PLAYER_INV];
		skill 		= new Skill[MAX_PLAYER_SKILLS];
		setName(name);
		//TODO: Generate character from class arctype
	}
	/**
	 * Sets the name of a stat.
	 * @param stat Index of the stat that will be modified.
	 * @param name New name of the stat.
	 */
	public static final void setStatName(int stat, String name)
	{
		if(stat < 4 && stat >= 0)
			STAT_NAME[stat] = name;
	}
	/**
	 * Returns the name of a stat.
	 * @param stat stat Index of the stat that will be modified.
	 */
	public static final String getStatName(int stat)
	{
		if(stat < 4 && stat >= 0)
			return STAT_NAME[stat];
		else
			return "";
	}
	/**
	 * Sets the name of the Character
	 * @param newName String that will be set as the new name of the Character.
	 */
	public final void setName(String newName)
	{
		name = newName;
	}
	/**
	 * Returns the name of the Character.
	 */
	public final String getName()
	{
		return name;
	}	
	/**
	 * Sets the HP value of the Character
	 * @param value Value to overwrite the HP value.
	 */
	public final void setHP(int value)
	{
		HP = value;
	}
	/** Returns the HP of the Character */
	public final int getHP()
	{
		return HP;
	}
	/**
	 * Sets the MP of the Character
	 * @param value Value to overwrite the Character's MP value.
	 */
	public final void setMP(int value)
	{
		MP = value;
	}
	/** Returns the MP of the Character */
	public final int getMP()
	{
		return MP;
	}
	/**
	 * Sets the SP of the Character
	 * @param value Value to overwrite the Character's SP value.
	 */
	public final void setSP(int value)
	{
		SP = value;
	}
	/**
	 * Returns the SP of the Character
	 */
	public final int getSP()
	{
		return SP;
	}
	/**
	 * Sets the STR of a character.
	 * @param value Value to overwrite the Character's STR value.
	 */
	public final void setStr(int value)
	{
		STR = value;
	}
	/** Returns the STR of a Character. */
	public final int getStr()
	{
		return STR;
	}
	/**
	 * Sets the DEX of a character.
	 * @param value Value to overwrite the Character's DEX value.
	 */
	public final  void setDex(int value)
	{
		DEX = value;
	}
	/** Returns the DEF of a character. */
	public final int getDex()
	{
		return DEX;
	}
	/**
	 * Sets the spirit of a character.
	 * @param value Value to overwrite the Character's spirit
	 */
	public final void setSpr(int value)
	{
		SPR = value;
	}
	/** Returns the speed of a character. */
	public final int getSpr()
	{
		return SPR;
	}
	/** 
	 * Sets the Magic of a character.
	 * @param value Value to overwrite the Character's magic.
	 */
	public final void setInt(int value)
	{
		INT = value;
	}
	/** Returns the magic of a character. */
	public final int getInt()
	{
		return INT;
	}
	/** 
	 * Sets the Inventory of a character.
	 * @param slot Inventory slot value.
	 * @param value Item value.
	 */
	public final void setInventory(int slot, Item item)
	{
		inventory[slot] = item.clone();
	}
	/** Returns the ItemValue of a Character's inventory slot. */
	public final Item getInventory(int slot)
	{
		return inventory[slot];
	}
	/** 
	 * Sets the Spell of a character.
	 * @param slot Spell slot value
	 * @param value Spell value.
	 */
	public final void setSkill(int slot, Skill skill)
	{
		this.skill[slot] = skill.clone();
	}
	/** Returns the Spell value of a Character's Spell slot. */
	public final Skill getSpell(int slot)
	{
		return this.skill[slot];
	}
	public final void setDef(int def) {
		this.def = def;
	}
	public final int getDef() {
		return def;
	}
	public final void setLvl(int lvl) {
		this.lvl = lvl;
	}
	public final int getLvl() {
		return lvl;
	}
	public final void setAccuracy(float accuracy) {
		this.accuracy = accuracy;
	}
	public final float getAccuracy() {
		return accuracy;
	}
	public final void setHand(int index, Item handEquip) {
		this.hand[index] = handEquip.clone();
	}
	public final Item getHand(int index) {
		return hand[index];
	}
	public final void setHit(int hit) {
		this.hit = hit;
	}
	public final int getHit() {
		return hit;
	}
	public final void unequipHand(int index)
	{
		this.hand[index] = null;
	}
	public final void setBuffed(boolean buffed) {
		this.buffed = buffed;
	}
	public final boolean isBuffed() {
		return buffed;
	}
	public final void setArms(Item arms) 
	{
		this.arms = arms.clone();
	}
	public final Item getArms() 
	{
		return arms;
	}
	public final void setBody(Item body)
	{
		this.body = body.clone();
	}
	public final Item getBody() 
	{
		return body;
	}
	public final void setHead(Item head) 
	{
		this.head = head.clone();
	}
	public final Item getHead() 
	{
		return head;
	}
	public final void setLegs(Item legs) 
	{
		this.legs = legs.clone();
	}
	public final Item getLegs() 
	{
		return legs;
	}
	public final void setNeck(Item neck)
	{
		this.neck = neck.clone();
	}
	public final Item getNeck() 
	{
		return neck;
	}
	public final void setRing(Item ring) 
	{
		this.ring = ring.clone();
	}
	public final Item getRing()
	{
		return ring;
	}
	public final void warp(int map, int layer, int x, int y)
	{
		//TODO: finish this.
	}
}
